home *** CD-ROM | disk | FTP | other *** search
- /*
-
- SheetCut.c Ko-Window ライブラリ 1991 小笠原博之
-
- SPS-NET: SPS0783 COR.
-
-
- Sheet の任意の位置から、任意の大きさの Sheet を取り出す。
-
- */
-
-
- #include <wlib.h>
-
- unsigned short mask[]= {
- 0x0000, 0x8000, 0xc000, 0xe000,
- 0xf000, 0xf800, 0xfc00, 0xfe00,
- 0xff00, 0xff80, 0xffc0, 0xffe0,
- 0xfff0, 0xfff8, 0xfffc, 0xfffe, 0xffff
- };
-
-
- SheetCut( sp, cp, x, y )
- Sheet *sp, /* 元データ */
- *cp; /* 取り出すバッファ */
- unsigned int x, /* 切り出す座標 */
- y;
- {
- unsigned int dy = sp->hword+ sp->hword,
- byte= dy*y + ((x&0xfff0)>>3),
- bit = x & 15;
- if( bit ){
- unsigned int bsize = (((bit+cp->h)&0xfff0)>>3)+2,
- i= cp->v;
- unsigned short sbuf[64],
- *sptr= (unsigned short*)(((char*)sp->buf1)+byte),
- *sptr2=(unsigned short*)(((char*)sp->buf2)+byte),
- *cptr= (unsigned short*)cp->buf1,
- *cptr2=(unsigned short*)cp->buf2,
- mskpat= mask[ cp->h - (cp->hword-1)*16 ];
-
- do{
- memcpyW( bsize>>1, sbuf, sptr );
- shiftL( bit, bsize, sbuf );
- memcpyW( cp->hword, cptr, sbuf );
- cptr[ cp->hword-1 ] &= mskpat;
- cptr+= cp->hword;
- sptr+= sp->hword;
- memcpyW( bsize>>1, sbuf, sptr2 );
- shiftL( bit, bsize, sbuf );
- memcpyW( cp->hword, cptr2, sbuf );
- cptr2[ cp->hword-1 ] &= mskpat;
- cptr2+= cp->hword;
- sptr2+= sp->hword;
- }while( --i );
- }else{
- dy= (sp->hword - cp->hword)*2;
- Scpy( dy, cp->v, cp->buf1, ((char*)sp->buf1)+byte, cp->hword );
- Scpy( dy, cp->v, cp->buf2, ((char*)sp->buf2)+byte, cp->hword );
- }
- }
-
-